import Instance from "./Instance.js"
import keyprompt from "./KeyPrompt.js"
import Plow from "./plow.js"

const Ashily = {


    update() {

        Ashily.MoveMent()
        Ashily.MoveShake()

    },

    onLayoutStart() {

        //Player entity
        Ashily.ashilyInstance = Instance.GetPickInstance("Ashily")
        //8 directional component
        Ashily.ashiliMoveBehavior = Ashily.ashilyInstance.behaviors.move


    },



    // Wobble as you move ：When the player moves, show the wobble
    MoveShake() {

        if (Ashily.ashiliMoveBehavior.speed > 30) {
            rt.callFunction("SwicthAshilyShake", 1)
        }

        if (Ashily.ashiliMoveBehavior.speed <= 30) {
            rt.callFunction("SwicthAshilyShake", 0)
            Ashily.ashilyInstance.angle = 0
        }


    },


    MoveMent() {

        if (rt.keyboard.isKeyDown("KeyA")) {
            Ashily.ashiliMoveBehavior.simulateControl("left")
            Instance.Flip(Ashily.ashilyInstance, true)
        }
        if (rt.keyboard.isKeyDown("KeyD")) {
            Ashily.ashiliMoveBehavior.simulateControl("right")
            Instance.Flip(Ashily.ashilyInstance, false)

        }
        if (rt.keyboard.isKeyDown("KeyW")) {
            Ashily.ashiliMoveBehavior.simulateControl("up")
        }
        if (rt.keyboard.isKeyDown("KeyS")) {
            Ashily.ashiliMoveBehavior.simulateControl("down")
        }


    },






}
export default Ashily